package com.team.coupon.api;

import com.team.common.core.web.domain.AjaxResult;
import com.team.coupon.api.domain.BizConsumeCouponDto;
import com.team.coupon.api.domain.BizUserCouponDto;
import com.team.coupon.api.factory.RemoteCouponFallbackFactory;
import com.team.coupon.api.factory.RemoteUserCouponFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(contextId = "remoteUserCouponService", value = "team-coupon-service", fallbackFactory = RemoteUserCouponFallbackFactory.class)
public interface RemoteUserCouponService {
    // 抢购优惠券
    @GetMapping("/coupon/grab")
    AjaxResult grabCoupon(@RequestBody BizUserCouponDto bizUserCoupon);

    // 根据用户id和发布主体id查询在该商铺可以使用的优惠券
    @GetMapping("/coupon/list")
    AjaxResult listCouponsByUserIdAndEntityId(@RequestParam("userId") Long userId,
                                                     @RequestParam("entityId") Long entityId);

    // 使用优惠券
    @PostMapping("/coupon/consumeCoupon")
    AjaxResult consumeCoupon(@RequestBody BizConsumeCouponDto bizConsumeCouponDto);

    // 根据用户id查找用户所有的优惠券
    @GetMapping("/coupon/listByUserId")
    AjaxResult listCouponsByUserId(@RequestParam("userId") Long userId);
}
